/**
 * 
 */
package com.lazyshopkeeper.front.apiService.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lazyshopkeeper.front.apiService.IShopService;
import com.lazyshopkeeper.front.common.Constant;
import com.taobao.api.ApiException;
import com.taobao.api.TaobaoClient;
import com.taobao.api.domain.SellerCat;
import com.taobao.api.domain.Shop;
import com.taobao.api.request.SellercatsListGetRequest;
import com.taobao.api.request.ShopGetRequest;
import com.taobao.api.response.SellercatsListGetResponse;
import com.taobao.api.response.ShopGetResponse;

/**
 * 淘宝店铺api接口实现
 * @author xuyuqi
 *
 */
@Service
public class ShopService implements IShopService {

	@Autowired
	private TaobaoClient client;
	
	/* (non-Javadoc)
	 * @see com.lazyshopkeeper.front.apiService.IShopService#getAllSellerCats(java.lang.String)
	 */
	@Override
	public List<SellerCat> getAllSellerCats(String nick) throws ApiException {
		SellercatsListGetRequest req=new SellercatsListGetRequest();
		req.setNick(nick);
		SellercatsListGetResponse response = client.execute(req);
		return response.getSellerCats();
	}

	/* (non-Javadoc)
	 * @see com.lazyshopkeeper.front.apiService.IShopService#getSellerShop(java.lang.String)
	 */
	@Override
	public Shop getSellerShop(String nick) throws ApiException {
		ShopGetRequest req=new ShopGetRequest();
		req.setFields(Constant.FILDS_SHOP);
		req.setNick(nick);
		ShopGetResponse response = client.execute(req);
		return response.getShop();
	}

}
